package own.stu.bytebuffer.sim.agent;

import net.bytebuddy.agent.builder.AgentBuilder;
import net.bytebuddy.description.type.TypeDescription;
import net.bytebuddy.dynamic.DynamicType;
import net.bytebuddy.utility.JavaModule;

import java.util.logging.Logger;

//@Slf4j
public class ByteBuddyListener implements AgentBuilder.Listener {
    // 当某个类将要被加载时就会回调此方法
    public void onDiscovery(String typeName, ClassLoader classLoader, JavaModule module, boolean loaded) {
        //log.info("onDiscovery {}", typeName);
    }

    // 对某个类完成了transform之后会回调
    public void onTransformation(TypeDescription typeDescription, ClassLoader classLoader, JavaModule module, boolean loaded, DynamicType dynamicType) {
        //log.info("onTransformation {}", typeDescription.getTypeName());
    }

    // 当某个类将要被加载了并且配置了被bytebuddy忽略
    public void onIgnored(TypeDescription typeDescription, ClassLoader classLoader, JavaModule module, boolean loaded) {
        //log.info("onIgnored {}", typeDescription.getTypeName());
    }

    public void onError(String typeName, ClassLoader classLoader, JavaModule module, boolean loaded, Throwable throwable) {
        //log.info("onError {}", typeName);
    }

    public void onComplete(String typeName, ClassLoader classLoader, JavaModule module, boolean loaded) {
        //log.info("onComplete {}", typeName);
    }
}
